<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android," />





  <link rel="alternate" href="/atom.xml" title="Swart的博客" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/assets/img/favicon.ico?v=5.1.1" />






<meta name="description" content="为什么要编译ijkplayer? 因为官方的Ijkplayer库是大多数项目中会用到的格式，如果不需要那么多格式，想要减小apk的体积、或者需要的格式比较多就需要重新编译了。  ##编译环境  系统：Ubuntu Kylin 16.04 LTS（我是装在win10系统下的虚拟机里的）">
<meta name="keywords" content="Android">
<meta property="og:type" content="article">
<meta property="og:title" content="在Ubuntu上编译ijkplayer">
<meta property="og:url" content="//swt6.win/2017/05/10/compileijkplayer/index.html">
<meta property="og:site_name" content="Swart的博客">
<meta property="og:description" content="为什么要编译ijkplayer? 因为官方的Ijkplayer库是大多数项目中会用到的格式，如果不需要那么多格式，想要减小apk的体积、或者需要的格式比较多就需要重新编译了。  ##编译环境  系统：Ubuntu Kylin 16.04 LTS（我是装在win10系统下的虚拟机里的）">
<meta property="og:updated_time" content="2017-05-11T15:17:52.133Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="在Ubuntu上编译ijkplayer">
<meta name="twitter:description" content="为什么要编译ijkplayer? 因为官方的Ijkplayer库是大多数项目中会用到的格式，如果不需要那么多格式，想要减小apk的体积、或者需要的格式比较多就需要重新编译了。  ##编译环境  系统：Ubuntu Kylin 16.04 LTS（我是装在win10系统下的虚拟机里的）">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '6X4GNQQN31',
      apiKey: '14f74f7248949b74fecc6e054f99f1a5',
      indexName: 'hexo',
      hits: {"per_page":10},
      labels: {"input_placeholder":"请输入搜索内容","hits_empty":"未找到相关结果: ${query}","hits_stats":"在${time} ms内发现${hits}条结果"}
    }
  };
</script>



  <link rel="canonical" href="//swt6.win/2017/05/10/compileijkplayer/"/>





  <title>在Ubuntu上编译ijkplayer | Swart的博客</title>
  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-99104344-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?361bb1900e6273da8b8e52413b849bbe";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Swart的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">别new了，再怎么new也不会有对象的</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-java">
          <a href="/tags/Java/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-code"></i> <br />
            
            Java
          </a>
        </li>
      
        
        <li class="menu-item menu-item-android">
          <a href="/tags/Android/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-android"></i> <br />
            
            Android
          </a>
        </li>
      
        
        <li class="menu-item menu-item-dandanplay">
          <a href="/tags/DanDanPlay" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-play-circle"></i> <br />
            
            弹弹Play
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="//swt6.win/2017/05/10/compileijkplayer/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Swart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/assets/img/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Swart的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">在Ubuntu上编译ijkplayer</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-10T21:36:45+08:00">
                2017-05-10
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="为什么要编译ijkplayer"><a href="#为什么要编译ijkplayer" class="headerlink" title="为什么要编译ijkplayer?"></a>为什么要编译ijkplayer?</h2><blockquote>
<p>因为官方的Ijkplayer库是大多数项目中会用到的格式，如果不需要那么多格式，想要减小apk的体积、或者需要的格式比较多就需要重新编译了。</p>
</blockquote>
<p>##编译环境</p>
<blockquote>
<p>系统：Ubuntu Kylin 16.04 LTS（我是装在win10系统下的虚拟机里的）</p>
<a id="more"></a>
<h2 id="先看下官方给出的步骤"><a href="#先看下官方给出的步骤" class="headerlink" title="先看下官方给出的步骤"></a>先看下官方给出的步骤</h2><p>原文参见：<a href="https://github.com/Bilibili/ijkplayer" target="_blank" rel="external">https://github.com/Bilibili/ijkplayer</a></p>
</blockquote>
<h3 id="Before-Build"><a href="#Before-Build" class="headerlink" title="Before Build"></a>Before Build</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"># install homebrew, git, yasm</div><div class="line">ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;</div><div class="line">brew install git</div><div class="line">brew install yasm</div><div class="line"></div><div class="line"># add these lines to your ~/.bash_profile or ~/.profile</div><div class="line"># export ANDROID_SDK=&lt;your sdk path&gt;</div><div class="line"># export ANDROID_NDK=&lt;your ndk path&gt;</div><div class="line"></div><div class="line"># on Cygwin (unmaintained)</div><div class="line"># install git, make, yasm</div></pre></td></tr></table></figure>
<ul>
<li><p>If you prefer more codec/format</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-default.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
</li>
<li><p>If you prefer less codec/format for smaller binary size (include hevc function)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-lite-hevc.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
</li>
<li><p>If you prefer less codec/format for smaller binary size (by default)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-lite.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
</li>
<li><p>For Ubuntu/Debian users.</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"># choose [No] to use bash</div><div class="line">sudo dpkg-reconfigure dash</div></pre></td></tr></table></figure>
</li>
<li><p>If you’d like to share your config, pull request is welcome.</p>
</li>
</ul>
<h3 id="Build-Android"><a href="#Build-Android" class="headerlink" title="Build Android"></a>Build Android</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div></pre></td><td class="code"><pre><div class="line">git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android</div><div class="line">cd ijkplayer-android</div><div class="line">git checkout -B latest k0.7.9</div><div class="line"></div><div class="line">./init-android.sh</div><div class="line"></div><div class="line">cd android/contrib</div><div class="line">./compile-ffmpeg.sh clean</div><div class="line">./compile-ffmpeg.sh all</div><div class="line"></div><div class="line">cd ..</div><div class="line">./compile-ijk.sh all</div><div class="line"></div><div class="line"># Android Studio:</div><div class="line">#     Open an existing Android Studio project</div><div class="line">#     Select android/ijkplayer/ and import</div><div class="line">#</div><div class="line">#     define ext block in your root build.gradle</div><div class="line">#     ext &#123;</div><div class="line">#       compileSdkVersion = 23       // depending on your sdk version</div><div class="line">#       buildToolsVersion = &quot;23.0.0&quot; // depending on your build tools version</div><div class="line">#</div><div class="line">#       targetSdkVersion = 23        // depending on your sdk version</div><div class="line">#     &#125;</div><div class="line">#</div><div class="line"># If you want to enable debugging ijkplayer(native modules) on Android Studio 2.2+: (experimental)</div><div class="line">#     sh android/patch-debugging-with-lldb.sh armv7a</div><div class="line">#     Install Android Studio 2.2(+)</div><div class="line">#     Preference -&gt; Android SDK -&gt; SDK Tools</div><div class="line">#     Select (LLDB, NDK, Android SDK Build-tools,Cmake) and install</div><div class="line">#     Open an existing Android Studio project</div><div class="line">#     Select android/ijkplayer</div><div class="line">#     Sync Project with Gradle Files</div><div class="line">#     Run -&gt; Edit Configurations -&gt; Debugger -&gt; Symbol Directories</div><div class="line">#     Add &quot;ijkplayer-armv7a/.externalNativeBuild/ndkBuild/release/obj/local/armeabi-v7a&quot; to Symbol Directories</div><div class="line">#     Run -&gt; Debug &apos;ijkplayer-example&apos;</div><div class="line">#     if you want to reverse patches:</div><div class="line">#     sh patch-debugging-with-lldb.sh reverse armv7a</div><div class="line">#</div><div class="line"># Eclipse: (obselete)</div><div class="line">#     File -&gt; New -&gt; Project -&gt; Android Project from Existing Code</div><div class="line">#     Select android/ and import all project</div><div class="line">#     Import appcompat-v7</div><div class="line">#     Import preference-v7</div><div class="line">#</div><div class="line"># Gradle</div><div class="line">#     cd ijkplayer</div><div class="line">#     gradle</div></pre></td></tr></table></figure>
<h3 id="Build-iOS"><a href="#Build-iOS" class="headerlink" title="Build iOS"></a>Build iOS</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios</div><div class="line">cd ijkplayer-ios</div><div class="line">git checkout -B latest k0.7.9</div><div class="line"></div><div class="line">./init-ios.sh</div><div class="line"></div><div class="line">cd ios</div><div class="line">./compile-ffmpeg.sh clean</div><div class="line">./compile-ffmpeg.sh all</div><div class="line"></div><div class="line"># Demo</div><div class="line">#     open ios/IJKMediaDemo/IJKMediaDemo.xcodeproj with Xcode</div><div class="line"># </div><div class="line"># Import into Your own Application</div><div class="line">#     Select your project in Xcode.</div><div class="line">#     File -&gt; Add Files to ... -&gt; Select ios/IJKMediaPlayer/IJKMediaPlayer.xcodeproj</div><div class="line">#     Select your Application&apos;s target.</div><div class="line">#     Build Phases -&gt; Target Dependencies -&gt; Select IJKMediaFramework</div><div class="line">#     Build Phases -&gt; Link Binary with Libraries -&gt; Add:</div><div class="line">#         IJKMediaFramework.framework</div><div class="line">#</div><div class="line">#         AudioToolbox.framework</div><div class="line">#         AVFoundation.framework</div><div class="line">#         CoreGraphics.framework</div><div class="line">#         CoreMedia.framework</div><div class="line">#         CoreVideo.framework</div><div class="line">#         libbz2.tbd</div><div class="line">#         libz.tbd</div><div class="line">#         MediaPlayer.framework</div><div class="line">#         MobileCoreServices.framework</div><div class="line">#         OpenGLES.framework</div><div class="line">#         QuartzCore.framework</div><div class="line">#         UIKit.framework</div><div class="line">#         VideoToolbox.framework</div><div class="line">#</div><div class="line">#         ... (Maybe something else, if you get any link error)</div><div class="line">#</div></pre></td></tr></table></figure>
<h2 id="接下来我们开始自己的编译"><a href="#接下来我们开始自己的编译" class="headerlink" title="接下来我们开始自己的编译"></a>接下来我们开始自己的编译</h2><h3 id="1-安装Java环境（已有可跳过）"><a href="#1-安装Java环境（已有可跳过）" class="headerlink" title="1.安装Java环境（已有可跳过）"></a>1.安装Java环境（已有可跳过）</h3><ul>
<li>保险起见请先在终端执行一次一下代码</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get update</div></pre></td></tr></table></figure>
<ul>
<li><p>然后检查是否安装了jdk</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">java -version</div></pre></td></tr></table></figure>
</li>
<li><p>如果出现了下面的输出结果，意味着你并没有安装过Java:</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">The program &apos;java&apos; can be found in the following packages:</div><div class="line"> * default-jre</div><div class="line"> * gcj-4.9-jre-headless</div><div class="line"> * gcj-5-jre-headless</div><div class="line"> * openjdk-8-jre-headless</div><div class="line"> * gcj-4.8-jre-headless</div><div class="line"> * openjdk-9-jre-headless</div><div class="line">Try: sudo apt install &lt;selected package&gt;</div></pre></td></tr></table></figure>
<ul>
<li>安装jdk命令如下：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">sudo add-apt-repository ppa:webupd8team/java</div><div class="line">sudo apt-get update</div><div class="line">sudo apt-get install oracle-java8-installer</div><div class="line">sudo apt-get install oracle-java8-set-default</div></pre></td></tr></table></figure>
<ul>
<li><p>安装成功后执行上面检查jdk的命令会看到如下输出：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">java version &quot;1.8.0_121&quot;</div><div class="line">Java(TM) SE Runtime Environment (build 1.8.0_121-b13)</div><div class="line">Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)</div></pre></td></tr></table></figure>
</li>
<li><p>到这里jdk就安装完成了<br>###2. 安装android开发SDK和NDK</p>
</li>
<li><p>首先新建一个文件夹，用来存放sdk和ndk(这步骤看个人习惯，可以放到其他目录去，我新建的目录名称是“Android”)：</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">mkdir Android</div></pre></td></tr></table></figure>
<ul>
<li>然后下载android的sdk:</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">cd Android/</div><div class="line">wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz</div><div class="line">tar -zxvf android-sdk_r24.4.1-linux.tgz</div><div class="line">echo &apos;export ANDROID_HOME=&quot;&apos;$HOME&apos;/Android/android-sdk-linux&quot;&apos; &gt;&gt; ~/.bashrc</div><div class="line">echo &apos;export PATH=&quot;$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools&quot;&apos; &gt;&gt; ~/.bashrc</div></pre></td></tr></table></figure>
<ul>
<li>然后重新打开终端，让环境变量生效。启动Android SDK Manager</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">android</div></pre></td></tr></table></figure>
<ul>
<li>之后来安装NDK：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">cd Android/</div><div class="line">wget https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip</div><div class="line">unzip android-ndk-r14b-linux-x86_64.zip</div><div class="line">echo &apos;export ANDROID_NDK=&quot;&apos;$HOME&apos;/Android/android-ndk-r14b&quot;&apos; &gt;&gt; ~/.bashrc</div><div class="line">echo &apos;export PATH=&quot;$PATH:$ANDROID_NDK&quot;&apos; &gt;&gt; ~/.bashrc</div></pre></td></tr></table></figure>
<ul>
<li><p>重启系统（到这步时不重启就不生效，也许只是我这里的个例）</p>
</li>
<li><p>启动终端，执行</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ndk-build</div></pre></td></tr></table></figure>
<p>​    若出现以下提示（只要没提示命令不存在就应该是安装成功了），这说明环境变量设置成功</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">Android NDK: Could not find application project directory !    </div><div class="line">Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.    </div><div class="line">/home/swart/Android/android-ndk-r14b/build/core/build-local.mk:151: *** Android NDK: Aborting    .  Stop.</div></pre></td></tr></table></figure>
<p>###3. 安装git、yasm</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">sudo add-apt-repository ppa:git-core/ppa</div><div class="line">sudo apt-get update</div><div class="line">sudo apt-get install git  </div><div class="line">sudo apt-get install yasm</div></pre></td></tr></table></figure>
<ul>
<li>安装下载完成后，可以使用下面的命令行，确认git和yasm是否安装成功，如果成功的话不会输出命令不存在的提示</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">git --version </div><div class="line">make</div></pre></td></tr></table></figure>
<p>###3. 正式开工、开始编译（以Android为例IOS、请参照官方文档即可）</p>
<ul>
<li>从git上拉取ijkplayer的源码：</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android</div><div class="line">cd ijkplayer-android</div><div class="line">git checkout -B latest k0.7.9</div><div class="line">#调整编译的类型的话需要在这行代码所在的位置做调整，调整方式在下面</div><div class="line">./init-android.sh</div><div class="line"></div><div class="line">cd android/contrib</div><div class="line">./compile-ffmpeg.sh clean</div><div class="line">./compile-ffmpeg.sh all</div><div class="line"></div><div class="line">cd ..</div><div class="line">./compile-ijk.sh all</div></pre></td></tr></table></figure>
<ul>
<li>调整编译类型</li>
</ul>
<p>   如果你需要支持更多的格式</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-default.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
<p>如果你需要较少的格式以便减小体积（支持hevc）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-lite-hevc.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
<p>如果你需要较少的格式以便减小体积（默认选择）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">cd config</div><div class="line">rm module.sh</div><div class="line">ln -s module-lite.sh module.sh</div><div class="line">cd android/contrib</div><div class="line"># cd ios</div><div class="line">sh compile-ffmpeg.sh clean</div></pre></td></tr></table></figure>
<ul>
<li>对于Ubuntu/Debian的用户<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"># choose [No] to use bash</div><div class="line">sudo dpkg-reconfigure dash</div></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li>编译完成后在/ijkplayer-android/android/ijkplayer目录下就生成了各个平台上所需的so文件</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/assets/img/weixinpay.png" alt="Swart WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/assets/img/alipay.jpg" alt="Swart Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        
  <ul class="post-copyright">
    <li class="post-copyright-author">
      <strong>本文作者：</strong>
      Swart
    </li>
    <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="//swt6.win/2017/05/10/compileijkplayer/" title="在Ubuntu上编译ijkplayer">//swt6.win/2017/05/10/compileijkplayer/</a>
    </li>
    <li class="post-copyright-license">
      <strong>版权声明： </strong>
      本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
    </li>
  </ul>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag"># Android</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/13/dandanplayupdatehistory/" rel="prev" title="弹弹play安卓版更新日志">
                弹弹play安卓版更新日志 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8yOTU0Ni82MTE0"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/assets/img/avatar.jpg"
               alt="Swart" />
          <p class="site-author-name" itemprop="name">Swart</p>
           
              <p class="site-description motion-element" itemprop="description">一个向前奔跑的Android程序猿</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/shiwentao666" target="_blank" title="github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  github
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://weibo.com/shiwentao666" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  微博
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.mybatis.org/spring/zh/" title="MyBatis-Spring文档" target="_blank">MyBatis-Spring文档</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://qbgbook.gitbooks.io/spring-boot-reference-guide-zh/" title="Spring-boot文档" target="_blank">Spring-boot文档</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://es6.ruanyifeng.com/" title="ECMAScript 6 入门" target="_blank">ECMAScript 6 入门</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#为什么要编译ijkplayer"><span class="nav-number">1.</span> <span class="nav-text">为什么要编译ijkplayer?</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#先看下官方给出的步骤"><span class="nav-number">2.</span> <span class="nav-text">先看下官方给出的步骤</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Before-Build"><span class="nav-number">2.1.</span> <span class="nav-text">Before Build</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Build-Android"><span class="nav-number">2.2.</span> <span class="nav-text">Build Android</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Build-iOS"><span class="nav-number">2.3.</span> <span class="nav-text">Build iOS</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#接下来我们开始自己的编译"><span class="nav-number">3.</span> <span class="nav-text">接下来我们开始自己的编译</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-安装Java环境（已有可跳过）"><span class="nav-number">3.1.</span> <span class="nav-text">1.安装Java环境（已有可跳过）</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Swart</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
  Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages </a>
</div>


        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  






  




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.1"></script>



  

  

  

  

  

  

  <script type="text/javascript" src="/lib/zclip/clipboard.min.js"></script>	
<script type="text/javascript" src="/js/src/custom.js"></script>
</body>
</html>
